package com.ps.controller;

import com.ps.property.PageBean;
import com.ps.property.ResponseVO;
import com.ps.property.SystemUserVo;
import com.ps.service.SystemUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author gt
 * @类说明：系统用户控制层
 * @date 2020/10/23 9:21
 */
@Api(tags = "系统用户接口")
@Controller
@Validated
@Slf4j
public class SystemUserController {
    @Autowired
    SystemUserService systemUserService;

    @ApiOperation(value = "新增系统用户信息接口",notes = "新增系统用户信息接口，新增系统用户")
    @PostMapping("/systemUserAdd-provide")
    @ResponseBody
    ResponseVO systemUserAdd(@Valid @RequestBody SystemUserVo systemUserVo) {

        return ResponseVO.success(systemUserService.systemUserAdd(systemUserVo));
    }

    @ApiOperation(value = "分页模糊查询系统用户信息接口",notes = "分页模糊查询系统用户信息接口，分页模糊查询系统用户")
    @ApiImplicitParams({@ApiImplicitParam(name = "currentPage", value = "当前页数", required = true),@ApiImplicitParam(name = "pageSize", value = "每页行数", required = true)})
    @GetMapping("/systemUserQueryByLike-provide")
    @ResponseBody
    ResponseVO systemUserQueryByLike(@RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize, @RequestParam("adminNickname") String adminNickname) {
        return ResponseVO.success(systemUserService.systemUserQuery(currentPage,pageSize,adminNickname));
    }

    @ApiOperation(value = "分页查询系统用户信息接口",notes = "分页查询系统用户信息接口，分页查询系统用户")
    @ApiImplicitParams({@ApiImplicitParam(name = "currentPage", value = "当前页数", required = true),@ApiImplicitParam(name = "pageSize", value = "每页行数", required = true)})
    @GetMapping("/systemUserQuery-provide")
    @ResponseBody
    ResponseVO systemUserQuery(@RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        log.info("系统用户当前页={}，每页行数={}",currentPage,pageSize);

        return ResponseVO.success(systemUserService.systemUserQuery(currentPage,pageSize,"%"));
    }

    @ApiOperation(value = "根据系统用户id修改系统用户信息接口",notes = "修改系统用户信息接口，修改系统用户")
    @ApiImplicitParam(name = "adminId",value = "系统用户ID",required = true)
    @PostMapping("/systemUserUpdate-provide")
    @ResponseBody
    ResponseVO systemUserUpdate(@Valid @RequestBody SystemUserVo systemUserVo) {
        return ResponseVO.success(systemUserService.systemUserUpdate(systemUserVo));
    }

    @ApiOperation(value = "根据系统用户id查询系统用户信息接口",notes = "查询系统用户信息接口，查询系统用户")
    @ApiImplicitParam(name = "adminId",value = "系统用户ID",required = true)
    @GetMapping("/systemUserQueryById-provide/{systemUserId}")
    @ResponseBody
    ResponseVO systemUserQueryById(@PathVariable int systemUserId) {
        return ResponseVO.success(systemUserService.systemUserQueryById(systemUserId));
    }
}
